import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'url'

const __filenameNew = fileURLToPath(import.meta.url)
const __dirnameNew = path.dirname(__filenameNew)


const viteConfig = defineConfig(({command,mode}) => {
  return {
    server: {
      host: '0.0.0.0',
      port: 3000,
      proxy: {
        '/api': {
          target: "http://127.0.0.1:8088",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        },
      }
    },
    // 解析
    resolve:{
      // 别名
      alias:{
        "@": path.resolve(__dirnameNew,"src"),
      },
    },
    plugins: [vue()],
  }
})

export default viteConfig